<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>短信邮件模板</title>
    <#include "/pubHeadStyle.html">
</head>
<body>
<div class="ccpui-tablesize" style="padding:10px;">
    <table id="noteTemplate" lay-filter="noteTemplate"></table>
</div>
<script type="text/html" id="noteTemplateToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <i class="layui-icon layui-icon-export"></i>
                <span>导出</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="import">
                <i class="layui-icon layui-icon-download-circle"></i>
                <span>导入</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" style="margin-top:10px" lay-filter="template">
            <div class="table-top-filter">
                <div class="table-filter-alone">
                    <label class="layui-form-label">模板名称 </label>
                    <input type="text" name="Q_name_SL" id="name" class="layui-input filter-value" placeholder="模板名称"
                           autocomplete="off"/>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label">模板用途 </label>
                    <select name="Q_useType_SN" id="useType" class="filter-value">
                        <option value="">------全部------</option>
                        <option value="1">终止提醒</option>
                        <option value="2">催办提醒</option>
                        <option value="3">审批提醒</option>
                        <option value="4">撤销提醒</option>
                        <option value="5">取消转办</option>
                        <option value="6">沟通提醒</option>
                        <option value="7">归档提醒</option>
                        <option value="8">转办提醒</option>
                        <option value="9">退回提醒</option>
                        <option value="10">沟通反馈</option>
                        <option value="11">取消代理</option>
                        <option value="12">抄送提醒</option>
                        <option value="13">流程节点无人员</option>
                        <option value="14">跟进事项预警</option>
                        <option value="15">跟进事项到期</option>
                        <option value="16">跟进事项完成</option>
                        <option value="17">跟进事项通知</option>
                        <option value="18">跟进事项已评价知会</option>
                        <option value="19">逾期提醒</option>
                        <option value="22">代理提醒</option>
                        <option value="23">消息转发</option>
                        <option value="24">重启任务</option>
                        <option value="25">通知任务所属人(代理)</option>
                        <option value="26">加签提醒</option>
                        <option value="27">加签反馈</option>
                        <option value="28">取消流转</option>
                        <option value="29">补签提醒</option>
                        <option value="30">创建人消息提醒</option>
                        <option value="31">交接提醒</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
</script>
<script type="text/html" id="manageBar">
    <a class="layui-btn layui-btn-xs" lay-event="default">设置默认</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="detail">明细</a>
</script>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'layer', 'jquery', 'form','setter','totalFilter','commons','common'],function () {
        var table = layui.table, layer = layui.layer,form = layui.form, setter = layui.setter,
            totalFilter = layui.totalFilter,commons = layui.commons, common = layui.common,$=layui.$;
        var tableH =commons.tabHeight();
        //渲染表格
        table.render({
            elem: '#noteTemplate'
            , cellMinWidth: 80
            , title: '模板管理列表'
            , defaultToolbar: []
            , height: tableH
            , url: serverPath.workflowPath + setter.workflowLinkPath + 'sysTemplate/list'
            , toolbar: '#noteTemplateToolsBar'
            , page: true
            , autoSort: false
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'name', title: '模板名称', sort: true,align: 'center'}
                , {field: 'useType', title: '模板用途', sort: true, align: 'center',
                    templet: function (d) {
                        var useType = d.useType;
                        switch (useType) {
                            case 1:
                                return "终止提醒";
                            case 2:
                                return "催办提醒";
                            case 3:
                                return "审批提醒";
                            case 4:
                                return "撤销提醒";
                            case 5:
                                return "取消转办";
                            case 6:
                                return "沟通提醒";
                            case 7:
                                return "归档提醒";
                            case 8:
                                return "转办提醒";
                            case 9:
                                return "退回提醒";
                            case 10:
                                return "沟通反馈";
                            case 11:
                                return "取消代理";
                            case 12:
                                return "抄送提醒";
                            case 13:
                                return "流程节点无人员";
                            case 14:
                                return "跟进事项预警";
                            case 15:
                                return "跟进事项到期";
                            case 16:
                                return "跟进事项完成";
                            case 17:
                                return "跟进事项通知";
                            case 18:
                                return "跟进事项已评价知会";
                            case 19:
                                return "逾期提醒";
                            case 22:
                                return "代理提醒";
                            case 23:
                                return "消息转发";
                            case 24:
                                return "重启任务";
                            case 25:
                                return "通知任务所属人（代理）";
                            case 26:
                                return "加签提醒";
                            case 27:
                                return "加签反馈";
                            case 28:
                                return "取消流转";
                            case 29:
                                return "补签提醒";
                            case 30:
                                return "创建人消息提醒";
                            case 31:
                                return "交接提醒";
                        }
                    }
                }
                , {field: 'isDefault', title: '是否默认', align: 'center',
                    templet: function (d) {
                        if (d.isDefault == 1) {
                            return '是';
                        }
                        return '否';
                    }
                }
                , {fixed: 'right', title: '管理', toolbar: '#manageBar', width: 300, align: 'center'}
            ]]
            ,done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });
        totalFilter.init('noteTemplate');
        table.on('toolbar(noteTemplate)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data; //获取选中行数据

            switch (obj.event) {
                case 'export':
                    if (data.length == 0) {
                        layer.confirm('请选择一条记录进行导出！',{skin: 'btn-class'});
                    } else {
                        layer.confirm('确定导出吗？',{
                            btn: ['确定', '取消'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].templateId);
                            }
                            var tableIds = ids.join(',');
                            var url = serverPath.workflowPath + setter.workflowLinkPath + 'sysTemplate/exportXml?ids=' + tableIds;
                            window.location.href = url;
                        });
                    }
                    break;
                case 'import':
                    //导入
                    var iframeWin;
                    layer.open({
                        type: 2,
                        title: "导入",
                        shade: 0.3,
                        area: ['500px', '250px'],
                        content: serverPath.workflowPath + setter.workflowLinkPath + "sysTemplate/view/importXml"
                    });
                    break;
                case 'query':
                    common.tableConditionRender("noteTemplate", "template", {where: {}}, false);
                    break;
                case 'add':
                    layer.open({
                        type: 2,
                        title: "新增",
                        area: ['700px', '620px'],
                        content:  serverPath.workflowPath + setter.workflowLinkPath+ "sysTemplate/view/sysTemplateEdit"
                    });
                    break;
                case 'reset':
                    common.tableConditionRender("noteTemplate", "template", {where: {}}, true);
                    break;
            }
        });

        //监听行工具事件
        table.on('tool(noteTemplate)', function (obj) {
            var data = obj.data;//获得当前行数据
            switch(obj.event){
                //设置默认
                case 'default':
                    if (data.isDefault != 1){
                        layer.confirm('确定将此信息置为默认吗？',{skin: 'btn-class'}, function(index) {
                            $.ajax({
                                url: serverPath.workflowPath + setter.workflowLinkPath + "sysTemplate/setDefault",
                                type: "post",
                                dataType: 'json',
                                data: {templateId: obj.data.templateId},
                                success: function (data) {
                                    layer.alert("设置成功！",{skin: 'btn-class'});
                                    table.reload('noteTemplate', {
                                        page: {
                                            curr: 1
                                        }
                                    });
                                }
                            });
                        });
                    }
                    break;
                case 'detail':
                    layer.open({
                        type: 2,
                        title: "明细",
                        shade: 0.3,
                        area: ['700px', '420px'],
                        content:  serverPath.workflowPath + setter.workflowLinkPath+ "sysTemplate/view/sysTemplateGet?templateId="+data.templateId

                    });

                    break;
                case 'del':
                    layer.confirm('确定删除当前数据吗？',{skin: 'btn-class'}, function () {
                        $.ajax({
                            url: serverPath.workflowPath + setter.workflowLinkPath + 'sysTemplate/del',
                            type:'post',
                            dataType: 'json',
                            data: {templateId: obj.data.templateId},
                            success: function (data) {
                                //提示消息
                                layer.alert("删除成功！",{skin: 'btn-class'});
                                //执行重载
                                table.reload('noteTemplate', {
                                    page: {
                                        curr: 1
                                    }
                                });
                                totalFilter.init('noteTemplate');
                            }
                        })
                    });
                    break;
                case 'edit':
                    layer.open({
                        type: 2,
                        title: "编辑",
                        shade: 0.3,
                        area: ['700px', '620px'],
                        content:  serverPath.workflowPath + setter.workflowLinkPath+ "sysTemplate/view/sysTemplateEdit?templateId="+data.templateId
                    });
                    break;
            }
        });

        common.tableSort("noteTemplate",{});
    })
</script>
</body>
</html>
<link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
<link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">